<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<body>
<ol class="am-pagination" th:fragment="pageNav(pageInfo, prevText, nextText, prefix)">
    <th:block th:if="${pageInfo.hasPreviousPage}">
        <li class="am-pagination-prev"><a th:href="@{'/'+${prefix}+'/'+${pageInfo.prePage}}" th:text="${prevText}"></a></li>
    </th:block>
    <th:block th:each="navIndex :${ pageInfo.navigatepageNums}">
        <th:block th:if="${pageInfo.pages} <= 5">
            <li th:class="${pageInfo.pageNum}==${navIndex}?'current':''">
                <a th:href="@{'/page/'+${navIndex}}" th:text="${navIndex}"></a>
            </li>
        </th:block>
        <th:block th:if="${pageInfo.pages} > 5">
            <li th:if="${pageInfo.pageNum <=3 &&  navIndex <= 5}" th:class="${pageInfo.pageNum}==${navIndex}?'current':''">
                <a th:href="@{'/page/'+${navIndex}}" th:text="${navIndex}"></a>
            </li>
            <li th:if="${pageInfo.pageNum >= pageInfo.pages-2 &&  navIndex > pageInfo.pages-5}" th:class="${pageInfo.pageNum}==${navIndex}?'current':''">
                <a th:href="@{'/page/'+${navIndex}}" th:text="${navIndex}"></a>
            </li>
            <li th:if="${pageInfo.pageNum >=4 && pageInfo.pageNum <= pageInfo.pages-3 &&  navIndex >= pageInfo.pageNum-2 && navIndex <= pageInfo.pageNum+2}"  th:class="${pageInfo.pageNum}==${navIndex}?'current':''">
                <a th:href="@{'/page/'+${navIndex}}" th:text="${navIndex}"></a>
            </li>
        </th:block>



    </th:block>
    <th:block th:if="${pageInfo.hasNextPage}">
        <li class="am-pagination-next"><a th:href="@{'/'+${prefix}+'/'+${pageInfo.nextPage}}" th:text="${nextText}"></a></li>
    </th:block>
</ol>

<div th:fragment="pageAdminNav(pageInfo)">
    <div class="clearfix">
        <ul class="pagination m-b-5 pull-right">
            <li th:if="${pageInfo.hasPreviousPage}">
                <a th:href="@{'?page='+${pageInfo.prePage}}" aria-label="Previous">
                    <i class="fa fa-angle-left"></i>&nbsp;上一页
                </a>
            </li>
            <th:block th:each="nav : ${pageInfo.navigatepageNums}">
                <li th:class="${nav==pageInfo.pageNum}?'active':''"><a th:href="@{'?page='+${nav}}" th:text="${nav}"></a>
                </li>
            </th:block>

            <th:block th:if="${pageInfo.hasNextPage}">
                <li>
                    <a th:href="@{'?page='+${pageInfo.nextPage}}" aria-label="Next">
                        下一页&nbsp;<i class="fa fa-angle-right"></i>
                    </a>
                </li>
            </th:block>

            <li><span th:text="'共'+${pageInfo.pages}+'页'"></span></li>
        </ul>
    </div>
</div>

</body>
</html>